import * as Cesium from 'cesium';
import * as lodash from 'lodash';
// apis
// hooks
// utils
import BaseMap from './BaseMap.ts';
// stores
// configs
import roadJson from '../../assets/json/road.json';
import cameraJson from '../../assets/json/camera.json';
import townJson from '../../assets/json/town.json';
// components
// emits
// refs
// computed
// methods
// watch
import roadImage from '../../assets/image/road.png';
import map_icon_camera from '../../assets/image/map_icon_camera.png';

export default class SuperMap extends BaseMap {
  constructor(props) {
    super(props);
    this.initMap();
  }

  // 初始化地图
  initMap = () => {
    try {
      this.initViewer();

      this.resetMouseActions();

      // this.addProviders();
      this.initCameraPosition();
    } catch (error) {
      console.warn(error);
    }
  };
  /**
   * 添加地图图层
   */
  addProviders = () => {
    try {
      this.addImageryLayerByUrlTemplateImageryProvider({
        key: 'local',
        urlTemplateImageryProvider: {
          url: 'https://wlxc.ikeqiao.net/MiLai_iclient_1000_file_source/yuecheng/localmap/{z}/{x}/{y}.png',
          minimumLevel: 3,
          maximumLevel: 18,
        },
      });
      this.addImageryLayerByUrlTemplateImageryProvider({
        key: 'road',
        urlTemplateImageryProvider: {
          url: 'https://wlxc.ikeqiao.net/MiLai_iclient_1000_file_source/yuecheng/road/{z}/{x}/{y}.png',
          minimumLevel: 3,
          maximumLevel: 18,
        },
      });
      setTimeout(() => {}, 5000);
    } catch (error) {
      console.warn(error);
    }
  };

  // 初始化相机位置
  initCameraPosition = () => {
    try {
      this.setCameraPositionByTargetLngLatHeight(
        { lng: 120.58196395955012, lat: 29.955897218424184, height: 0 },
        {
          heading: 0,
          pitch: -45,
          roll: 0,
        },
      );
      this.addCircle(
        {
          lng: 120.58196395955012,
          lat: 29.955897218424184,
        },
        {
          key: 'circle',
          ellipse: {
            semiMajorAxis: 1000,
            semiMinorAxis: 1000,
            height: 0,
            material: Cesium.Color.RED.withAlpha(0.2),
            outline: true,
            outlineColor: Cesium.Color.RED,
          },
        },
      );
      this.addCircle(
        {
          lng: 120.58196395955012,
          lat: 29.955897218424184,
        },
        {
          key: 'circle2',
          ellipse: {
            semiMajorAxis: 2000,
            semiMinorAxis: 2000,
            height: 0,
            material: Cesium.Color.WHITE.withAlpha(0.2),
            outline: true,
            outlineColor: Cesium.Color.WHITE,
          },
        },
      );
    } catch (error) {
      console.warn(error);
    }
  };
}
